<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.db.conn"%>
<%@ page import="com.db.Pagination"%>
<%@ page import="java.sql.*"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>


<jsp:include flush="true" page="${basePath}/admin/head.jsp"></jsp:include>
 <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">管理客户信息</h3>
            </div>
            <div class="panel-body" style="min-height: 500px;">
           <table style="width:100%;"><tr><td align="center">
  <table class="layui-table" style="width:98%;margin-left:10px;" align="center">
                    <tbody>
                 <tr>
                <td align="center">
                                    <form action="<%=path %>/admin/members/members_Manage.jsp" method="post">

<strong> 微信昵称:</strong><input name="txt_mnic" type="text" id="txt_mnic" style="width:150px;"  />
<strong> 姓名:</strong><input name="txt_mname" type="text" id="txt_mname" style="width:150px;"  />
<strong> 手机号码:</strong><input name="txt_tel" type="text" id="txt_tel" style="width:150px;"  />
<strong> 身份证号:</strong><input name="txt_card" type="text" id="txt_card" style="width:150px;"  />

                <input name="search" type="submit" border="0" class="btn btn-info"	value='查询' />
                </form>

   </td>
            </tr>
             <tr>
                <td align="center">
                      <%
//定义四个分页会用到的变量
int pageSize=15;
int pageNow=1;//默认显示第一页
int rowCount=0;//该值从数据库中查询
int pageCount=0;//该值是通过pageSize和rowCount
//接受用户希望显示的页数（pageNow）
String s_pageNow=request.getParameter("pageNum");
if(s_pageNow!=null){
//接收到了pageNow
pageNow=Integer.parseInt(s_pageNow);
}

String where="  1=1 ";
if(request.getParameter("txt_mnic")!=null)
{
where+=" and mnic like '%"+request.getParameter("txt_mnic")+"%' ";
}

if(request.getParameter("txt_mname")!=null)
{
where+=" and mname like '%"+request.getParameter("txt_mname")+"%' ";
}

if(request.getParameter("txt_tel")!=null)
{
where+=" and tel like '%"+request.getParameter("txt_tel")+"%' ";
}

if(request.getParameter("txt_card")!=null)
{
where+=" and card like '%"+request.getParameter("txt_card")+"%' ";
}


conn cn=new conn();


ResultSet rs=cn.query("select count(*) from members a where "+where);
if(rs.next()){
rowCount=rs.getInt(1);
}

//计算pageCount
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
//查询出需要显示的记录
 
rs=cn.query("select  * from members a where "+where+" order by mid desc limit "+pageSize*(pageNow-1)+", "+pageSize);

%>

	<table cellspacing="0" border="0" style="width:100%;border-collapse:collapse;"  >
		<tr>
    <th >微信昵称</th>
    <th >微信头像</th>
    <th >姓名</th>
    <th >性别</th>
    <th >手机号码</th>
    <th >身份证号</th>
    <th >联系地址</th>
    <th >注册时间</th>
			<th scope="col">操作</th>		</tr>
		<%
while(rs.next()){
%>
		<tr align="center" >
  			<td><%=rs.getString("mnic") %></td>
 <td align="center"><img alt="" src="<%=rs.getString("mpic") %>" width="80"  height="80" /></td>
  			<td><%=rs.getString("mname")==null?"":rs.getString("mname") %></td>
  			<td><%=rs.getString("sex")==null?"":rs.getString("sex") %></td>
  			<td><%=rs.getString("tel")==null?"":rs.getString("tel") %></td>
  			<td><%=rs.getString("card")==null?"":rs.getString("card") %></td>
  			<td><%=rs.getString("address")==null?"":rs.getString("address") %></td>
  			<td><%=rs.getString("mtime") %></td>
			<td >
           <a href="<%=path %>/admin/members/members_Detail.jsp?id=<%=rs.getString("mid") %>">详细</a>&nbsp;
           <a href="<%=path %>/members_Delete?id=<%=rs.getString("mid") %>">删除</a>
		</tr>
<%} %>
  
					   </table>
             		 <table width=100%>
			 <tbody>
               <tr>
                <td align="center">
                       <%= Pagination.getPagination(pageNow,pageCount,rowCount,request.getRequestURI()) %>    
              </td>
              </tr>
                    </tbody>
                </table>
   </td></tr></table>
            

            </div>
        </div>




